<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateOtherExtendRecordTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        //用户优惠券发放记录表
        Schema::create('bonus_extend_record', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->boolean('is_success')->default(false)->comment('是否发放成功');
            $table->string('fail_reason')->comment('发送失败原因')->default('未知原因');
            $table->unsignedBigInteger('record_id')->comment('对应的优惠券')->nullable();
            $table->foreign('record_id')->references('id')->on('bonus_record');
            $table->string('no')->comment('第三方发送编号 以便于追溯失败原因(第三方定义)')->default('null');
            $table->timestamps();
        });

        //第三方添加用户记录表
        Schema::create('user_extend_record', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->boolean('is_success')->default(false)->comment('是否发放成功');
            $table->string('fail_reason')->comment('发送失败原因')->default('未知原因');
            $table->unsignedBigInteger('record_id')->comment('对应的用户表')->nullable();
            $table->foreign('record_id')->references('id')->on('user');
            $table->string('no')->comment('第三方发送编号 以便于追溯失败原因(第三方定义)')->default('null');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('bonus_extend_record');
    }
}
